import router from '@/router';
import { $Http } from '@/config/service/http';
import $Subject from './subject';
import * as Icons from '@ant-design/icons-vue';

export function setupGlobFun(app: any, data: any) {
  app.config.globalProperties.$Http = $Http;
  app.config.globalProperties.$NotificationPubSub = $Subject.$NotificationPubSub;
  app.config.globalProperties.$NotificationFormSub = $Subject.$NotificationFormSub;
  app.config.globalProperties.$goTo = function (name: any, query: any = {}) {
    router.push({ name, query: query });
  };
  //定义自带icon
  app.config.globalProperties.$icons = Icons;
  for (const key in Icons) {
    app.component(key, Icons[key]);
  }
  if (data) {
    app.config.globalProperties.$parentRouter = data.router;
  }
}
